package com.zhiqingchun.web.user;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.zhiqingchun.dao.contact.ContactResult;
import com.zhiqingchun.dao.contact.IContactDao;
import com.zhiqingchun.pojo.UsrContactDO;

@Controller
@RequestMapping("/cancelNoticeUser.html")
public class CancelNoticeUserController {

	@RequestMapping(method = RequestMethod.POST)
	public String cancelNoticeUser(ModelMap map, HttpServletRequest request, HttpServletResponse response,
			Integer id, Integer myId) {
		if (id != null && myId != null) {
			UsrContactDO usrContactDO = new UsrContactDO();
			usrContactDO.setUserId(myId);
			usrContactDO.setContactId(id);
			ContactResult contactResult = contactDao.remove(usrContactDO);
			boolean result = false;
			if (contactResult.isSuccess()) {
				result = true;
			}
			try {
				PrintWriter out = response.getWriter();
				out.print(result);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	
	@Autowired
	private IContactDao contactDao;

	public IContactDao getContactDao() {
		return contactDao;
	}

	public void setContactDao(IContactDao contactDao) {
		this.contactDao = contactDao;
	}
}
